<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/18 0018
 * Time: 下午 1:49
 */
use yii\helpers\Url;
use common\models\WxPublic\WxPublic;
\backend\assets\CodeMirrorAsset::register($this)
?>
<?php $this->beginBlock("content");?>
<div class="row">
    <div class="col-md-12 white-box">
        <form action="<?=Url::to(["set"])?>" method="post" rel-action="form" rel-before="submitBefore" >

            <div class="row ">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">
                            公众号名称
                        </label>
                        <input type="text" name="name" value="<?=@$ret["name"]?>" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="name"></div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label">
                            APP ID
                        </label>
                        <input type="text" name="app_id" value="<?=@$ret["app_id"]?>" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="app_id"></div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label">
                            Secret
                        </label>
                        <input type="text" name="secret" value="<?=@$ret["secret"]?>" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="app_id"></div>
                    </div>
                </div>
            </div>
            <div class="row ">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">
                            终止关注数
                        </label>
                        <input type="text" name="stop_follow_num" value="<?=@$ret["stop_follow_num"]?>" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="stop_follow_num"></div>
                    </div>
                </div>
            </div>
            <div class="row ">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">
                            曝光率%
                        </label>
                        <input type="text" name="exposure_rate" value="<?=@$ret["exposure_rate"]?>" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="exposure_rate"></div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">状态</label>
                        <div class="radio-list">
                            <?php foreach (WxPublic::getStatusMap() as $key => $item): ?>
                                <label class="radio-inline p-0">
                                    <div class="radio radio-success">
                                        <input type="radio" name="status" id="status<?=$key?>" value="<?=$key?>" <?php if (@$ret['status'] == $key) : ?>checked<?php endif ?>>
                                        <label for="status<?=$key?>"><?=$item?></label>
                                    </div>
                                </label>
                            <?php endforeach ?>
                            <div class="form-control-feedback" rel-mark="status">
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">投放区域</label>
                        <textarea  class="form-control " rows="5" name="disabled_area" placeholder="逗号分隔城市"><?=@$area?></textarea>
                        <div class="form-control-feedback" rel-mark="content"></div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">自定义回复消息</label>
                        <textarea   class="form-control codeMirror" rows="5" rel-auto="300px" name="reply_msg" placeholder=""><?=@$ret["reply_msg"]?></textarea>
                        <div class="form-control-feedback" rel-mark="reply_msg"></div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">公众号菜单JSON</label>
                        <textarea   class="form-control codeMirror" rows="5" rel-auto="900px" name="menu" placeholder=""><?=@$ret["menu"]?></textarea>
                        <div class="form-control-feedback" rel-mark="menu"></div>
                    </div>
                </div>
            </div>
            <?php if (isset($ret["id"])):?>
                <input type="hidden" name="id" value="<?=$ret["id"]?>">
            <?php endif?>
            <button type="submit" class="btn btn-success waves-effect waves-light m-r-10 float-left">
                确认保存
            </button>
            <button type="button" class="btn btn-default waves-effect waves-light m-r-10" onclick="location.href='<?=Url::to(["index"])?>'">
                返回列表
            </button>
        </form>
    </div>

</div>
<?php $this->endBlock();?>
<?php $this->beginBlock("script")?>
<script>
    function submitBefore() {
        var password = $("[name=password]").val()
        var password2 = $("[name=password2]").val()
        if ( password && password != password2 ) {
            return {
                status: 0,
                message: "两次密码不一致"
            }
        }
        return true;
    }
    function agentParentChange(){
        var val = $("#parent_agent").find("option:selected").val()
        if ( val > 0 ) {
            $("#manager").hide()
        } else {
            $("#manager").show()
        }
    }
    agentParentChange()
    $("#parent_agent").change(agentParentChange)
</script>
<?php $this->endBlock();?>
